package crond

import (
	"mini-app/config/mysql"
	"mini-app/internal/models"
	"time"
)

// pickupOrderCheck 订单取货超时检测
func pickupOrderCheck() error {
	// 订单为取货状态，截止时间小于当前时间
	db := mysql.NewDB()
	db.Model(&models.Order{}).
		Where("purchase_method = 1").                                            // 站点自提
		Where("pickup_status = 0").                                              // 未取货
		Where("pickup_deadline > 0 and pickup_deadline < ?", time.Now().Unix()). // 时间已过
		UpdateColumn("pickup_status", 2)                                         // 2 已超时
	return nil
}
